from datetime import timedelta
import logging
from redis import StrictRedis


class Config(object):
    # 设置配置信息
    # 调试信息
    DEBUG = True

    #SECRET_KEY配置
    SECRET_KEY = 'dfsdfsdfsdd'

    #数据库配置信息
    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:mysql@localhost:3306/info36'
    # 设置警告追踪为False提高性能
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # redis配置信息
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    # 配置session
    SESSION_TYPE = 'redis'
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)
    SESSION_USE_SIGNER = True
    PERMANENT_SESSION_LIFETIME = timedelta(days=2)
    LEVEL_NAME = logging.DEBUG


# 开发环境配置信息
class DevelopConfig(Config):
    pass


# 生产环境配置信息
class Product_Config(Config):
    LEVEL_NAME = logging.ERROR
    pass


# 测试环境配置信息
class TestConfig(Config):
    pass


# 提供一个统一的访问信息
config_dict = {
    "develop": DevelopConfig,
    "product": Product_Config,
    "test": TestConfig
}